package app.ep1.test;

import android.test.ActivityInstrumentationTestCase2;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import app.ep1.seminarios.ListaAlunosSeminarioActivity;
import app.ep1.R;

public class ListaAlunosSeminarioValidation extends
		ActivityInstrumentationTestCase2<ListaAlunosSeminarioActivity> {
	public ListaAlunosSeminarioValidation() {
		super("app.ep1.seminarios", ListaAlunosSeminarioActivity.class);
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
	}

	public void testAdicionaLinhaDeAluno() throws Throwable {
		final ListaAlunosSeminarioActivity listaAlunosSeminarioActivity = getActivity();

		final String nusp = "12345";

		runTestOnUiThread(new Runnable() {
			@Override
			public void run() {
				listaAlunosSeminarioActivity.adicionaLinhaDeAluno(nusp);
			}
		});

		TableLayout tableLayout = (TableLayout) listaAlunosSeminarioActivity
				.findViewById(R.id.tableLayoutAlunosSeminario);

		int indice = tableLayout.getChildCount();
		TableRow tableRow = (TableRow) tableLayout.getChildAt(indice - 1);

		TextView textView = (TextView) tableRow.getChildAt(0);

		assertEquals(nusp, textView.getText().toString());
	}
}
